//
//  ZJPickerView.m
//  这家测试项目
//
//  Created by IOS_DEVELOPER on 2017/7/10.
//  Copyright © 2017年 陈志凌. All rights reserved.
//

#import "ZJPickerView.h"

@interface ZJPickerView ()<UIPickerViewDelegate,UIPickerViewDataSource>
@property (weak, nonatomic) IBOutlet UIPickerView *pickerView;
@property (weak, nonatomic) IBOutlet UILabel *mainTitle;
@property (strong, nonatomic) NSArray * dataArr;
@end

@implementation ZJPickerView

- (void)viewDidLoad {
    [super viewDidLoad];
     self.dataArr = @[@"中国银行",@"中国农业银行",@"中国工商银行",@"中国建设银行"];
}

- (IBAction)cancelBtn:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)sureBtn:(UIButton *)sender {
    if (_delegate != nil){
        [_delegate clickBank:self.mainTitle.text];
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma Mark -- UIPickerViewDataSource
// pickerView 列数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 1;
}

// pickerView 每列个数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    
    return [_dataArr count];
}
#pragma Mark -- UIPickerViewDelegate
// 每列宽度
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
    
    return SCREEN_WIDTH;
}

// 返回选中的行
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    self.mainTitle.text =self.dataArr[row];
    
}
// 返回第 component 列第 row 行的标题
- (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    
    return _dataArr[row];
}
@end
